#ifndef __EXLOBBY_AVATAR_GAME_MGR_H__
#define __EXLOBBY_AVATAR_GAME_MGR_H__

#include "ExLobbyDDL.h"
//#include <ServerBase.h>
#include <ServerUtils.h>
#include <set>

namespace Atlas
{
	class CExLobbyAvatarNodeClient;
	class CRoomInfo;

	class CRoomInfo
	{
	public:
		CRoomInfo(const ROOM_INFO& RoomInfo, _U64 nndx);
		~CRoomInfo();
		_U64 GetNNDX();
		ROOM_INFO& GetRoomInfo();
		bool NeedDelete(); 
		void AddClient(CExLobbyAvatarNodeClient* pClient);
		std::set<CExLobbyAvatarNodeClient*>& GetClients();
		void DelClient(CExLobbyAvatarNodeClient* pClient);

		void SetExistState(bool bIsExit);

	private:
		ROOM_INFO m_RoomInfo;
		_U64 m_nndx;
		std::set<CExLobbyAvatarNodeClient*> m_SetClient;
		bool m_bIsExit;
	};

	template<>
	CRoomInfo* CObjectLocker<CRoomInfo>::Lock(_U64 ndx);

	template<>
	void CObjectLocker<CRoomInfo>::Unlock(_U64 ndx);

	class GameMgr
	{
	public:
		GameMgr();
		~GameMgr();

		void CreateRoom(CExLobbyAvatarNodeClient* pClient, const char* name);
		void EnterRoom(CExLobbyAvatarNodeClient* pClient, _U64 id);
		void LeaveRoom(CExLobbyAvatarNodeClient* pClient);
		void ListRoom(CExLobbyAvatarNodeClient* pClient, _U64 id);

		void SendMsg(CExLobbyAvatarNodeClient* pClient, const char* msg);

	public:
		CRoomInfo* CreateRoomInfo(_U64 ndx);

	private:
		A_MUTEX m_RoomLock;
	};
}

#endif //__EXLOBBY_AVATAR_GAME_MGR_H__